
/**
 * AppleIIGo
 * Paddles class
 * (C) 2007-2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */
 
#include "Motherboard.h"

#ifndef PADDLES_H
#define PADDLES_H

#define PADDLEPOSITION_LOW		0
#define PADDLEPOSITION_CENTER	127
#define PADDLEPOSITION_HIGH		255

#define ANNUNCIATOR_0		(1 << 0)
#define ANNUNCIATOR_1		(1 << 1)
#define ANNUNCIATOR_2		(1 << 2)
#define ANNUNCIATOR_3		(1 << 3)

#define PADDLEBUTTON_NUM	3
#define PADDLEAXIS_NUM		4

class Paddles : public Device {
public:
	Paddles(class Motherboard * motherboard);
	
	void onDevicesConnected();
	void onResetAsserted(bool isRestart);
	
	void setAnnunciator(UINT32 index, bool value);
	bool getAnnunciator(UINT32 index);
	
	void pushButton(UINT32 index);
	void pullButton(UINT32 index);
	bool isButtonDown(UINT32 index);
	
	void setPosition(UINT32 paddle, UINT32 position);
	void resetTimer();
	bool isTimedOut(UINT32 paddle);
	
private:
	class TimingGenerator * timingGenerator;
	
	UINT8 annunciatorRegister;
	
	UINT32 buttonCount[PADDLEBUTTON_NUM];
	
	UINT64 timerLength[PADDLEAXIS_NUM];
	UINT64 timerIndex[PADDLEAXIS_NUM];
	
	void initButton(UINT32 index);
};

#endif
